/* SPDX-License-Identifier: GPL-2.0 */
/*
 * CFS watchdog header file.  Only to be included by cfs_watchdog module.
 */
#ifndef _CFS_WDT_H
#define _CFS_WDT_H

#define CFS_WD_LOG_RATELIMIT_INTERVAL	(10 * 60 * HZ)
#define CFS_WD_LOG_RATELIMIT_BURST	1

#define CFS_WD_SAMPLE_PERIODE_MIN	200
#define CFS_WD_THRESH_MIN		1000

#define CFS_WD_THRESH_DEFAULT		(20 * MSEC_PER_SEC)
#define CFS_WD_SAMPLE_PERIODE_DEFAULT	(4 * MSEC_PER_SEC)

#define CFS_WDT_ENABLED			1
#define CFS_WD_MODE_MAX_VAL		CFS_WDT_ENABLED

#ifdef CONFIG_SYSFS
struct cfs_watchdog_attr {
	struct attribute attr;
	ssize_t (*show)(struct  kobject *kobj, struct kobj_attribute *attr, char *buf);
	ssize_t (*store)(struct  kobject *kobj, struct kobj_attribute *attr,
			  const char *buf, size_t count);
};

#define define_one_rw(_name) \
	static struct cfs_watchdog_attr _name = \
__ATTR(_name, 0600, _name##_show, _name##_store)

static ssize_t mode_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf);
static ssize_t mode_store(struct kobject *kobj, struct kobj_attribute *attr,
						const char *buf, size_t count);

static ssize_t thresh_ms_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf);
static ssize_t thresh_ms_store(struct kobject *kobj, struct kobj_attribute *attr,
						const char *buf, size_t count);

static ssize_t sample_period_ms_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf);
static ssize_t sample_period_ms_store(struct kobject *kobj, struct kobj_attribute *attr,
						const char *buf, size_t count);
static ssize_t cpusmask_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf);
static ssize_t cpusmask_store(struct kobject *kobj, struct kobj_attribute *attr,
						const char *buf, size_t count);

static ssize_t log_ratelimit_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf);
static ssize_t log_ratelimit_store(struct kobject *kobj, struct kobj_attribute *attr,
						const char *buf, size_t count);

static ssize_t log_ratelimit_burst_show(struct kobject *kobj,
					struct kobj_attribute *attr, char *buf);
static ssize_t log_ratelimit_burst_store(struct kobject *kobj, struct kobj_attribute *attr,
						const char *buf, size_t count);
#endif /* CONFIG_SYSFS */

extern unsigned long long sched_clock(void);
#endif

